import logging

from fastapi import APIRouter

from stats.conf.conf import neo4j_database_stats_adapter
from stats.model.system_stats import DatabaseStats


logger = logging.getLogger(__name__)

router = APIRouter(
    prefix="/stats",
    tags=["stats"],
)

stats_adapter = neo4j_database_stats_adapter()


@router.get("", response_model=DatabaseStats, response_model_exclude_none=True)
async def fetch_database_stats():
    # todo: add daily caching
    return stats_adapter.query_system_stats()
